home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 March / EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso / earcd / program / ixemlsrc.lha / ixemul / utils / main.c < prev    next >
C/C++ Source or Header  |  1995-12-23  |  4KB  |  170 lines

  1. /*
  2.     Ixprefs v.2.1--ixemul.library configuration program
  3.     Copyright © 1995 Kriton Kyrimis
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23. #include <exec/types.h>
  24. #include <dos/dos.h>
  25. #include <intuition/intuition.h>
  26. #include <proto/exec.h>
  27. #include <proto/intuition.h>
  28. #include <proto/gadtools.h>
  29. #include "ixemul.h"
  30. #include "ixprefs.h"
  31.  
  32. void cleanup(void);
  33. void displayprefs(void);
  34. void showrequester(struct Window*, char *, char *);
  35. extern int parse_cli_commands(int argc, char *argv[]);
  36.  
  37. extern struct ixemul_base *ixemulbase;
  38. int translateslash, membuf, watcher, redzone, blocks, cases, suppress,
  39.     amigawildcard, noflush, ignoreenv, networking;
  40.  
  41. char ixprefs_version[] = "$VER: ixprefs 2.1 (14.11.95)";
  42.  
  43. int
  44. main(int argc, char *argv[])
  45. {
  46.   long status;
  47.  
  48.   if (ixemulbase->ix_lib.lib_Version < 42) {
  49.     showrequester(NULL,
  50.     "This program requires ixemul.library version 42 or higher",
  51.     "EXIT");
  52.     return RETURN_FAIL;
  53.   }
  54.  
  55.   (void)ixprefsrestore();    /* load ixprefs settings from ixemulbase */
  56.   
  57.   if (argc >= 2) {
  58.     return parse_cli_commands(argc, argv);
  59.   }
  60.  
  61.   atexit(cleanup);
  62.  
  63.   status = SetupScreen();
  64.   if (status != 0) {
  65.     fprintf(stderr, "SetupScreen failed, status = %ld\n", status);
  66.     return RETURN_FAIL;
  67.   }
  68.   ixprefsTop=Scr->BarHeight+1;
  69.   status = OpenixprefsWindow();
  70.   if (status != 0) {
  71.     fprintf(stderr, "OpenixprefsWindow failed, status = %ld\n", status);
  72.     return RETURN_FAIL;
  73.   }
  74.  
  75.   displayprefs();
  76.  
  77.   while (1) {
  78.     WaitPort(ixprefsWnd->UserPort);
  79.     status = HandleixprefsIDCMP();
  80.     if (status == 0) {
  81.       return RETURN_OK;
  82.     }
  83.   }
  84.   return 0;
  85. }
  86.  
  87. void
  88. cleanup()
  89. {
  90.   CloseixprefsWindow();
  91.   CloseDownScreen();
  92. }
  93.  
  94. void
  95. check(int which)
  96. {
  97.   ixprefsGadgets[which]->Flags |= GFLG_SELECTED;
  98. }
  99.  
  100. void
  101. uncheck(int which)
  102. {
  103.   ixprefsGadgets[which]->Flags &= ~GFLG_SELECTED;
  104. }
  105.  
  106. void
  107. showchecked(int which, int checkit)
  108. {
  109.   if (checkit) {
  110.     check(which);
  111.   }else{
  112.     uncheck(which);
  113.   }
  114.   RefreshGList(ixprefsGadgets[which], ixprefsWnd, NULL, 1);
  115. }
  116.  
  117. void
  118. shownum(int which, int num)
  119. {
  120.   sprintf(GetString(ixprefsGadgets[which]), "%d", num);
  121.   GetNumber(ixprefsGadgets[which]) = num;
  122.   RefreshGList(ixprefsGadgets[which], ixprefsWnd, NULL, 1);
  123. }
  124.  
  125. void
  126. showcycle(int which, int num)
  127. {
  128.   GT_SetGadgetAttrs(ixprefsGadgets[which], ixprefsWnd, NULL,
  129.             GTCY_Active, num, TAG_DONE);
  130.   RefreshGList(ixprefsGadgets[which], ixprefsWnd, NULL, 1);
  131. }
  132.  
  133. void
  134. displayprefs(void)
  135. {
  136.   if (Scr == NULL)
  137.     return;
  138.   showchecked(GDX_amigawildcard, amigawildcard);
  139.   showchecked(GDX_case, cases);
  140.   showchecked(GDX_translateslash, translateslash);
  141.   shownum(GDX_membuf, membuf);
  142.   showchecked(GDX_watcher, watcher);
  143.   shownum(GDX_redzone, redzone);
  144.   shownum(GDX_blocks, blocks);
  145.   showchecked(GDX_suppress, suppress);
  146.   showchecked(GDX_noflush, noflush);
  147.   showchecked(GDX_ignoreenv, ignoreenv);
  148.   showcycle(GDX_networking, networking);
  149. }
  150.  
  151. void
  152. showrequester(struct Window *win, char *text, char *buttontext)
  153. {
  154.   static struct EasyStruct easy = {
  155.     sizeof(struct EasyStruct),
  156.     0,
  157.     "ixprefs",
  158.     NULL,
  159.     NULL,
  160.   };
  161.  
  162.   if (win /*|| strchr(buttontext, '|')*/) {
  163.     easy.es_TextFormat = (UBYTE *)text;
  164.     easy.es_GadgetFormat = (UBYTE *)buttontext;
  165.     EasyRequest(NULL, &easy, NULL);
  166.   }else{
  167.     fprintf(stderr, "%s\n", text);
  168.   }
  169. }
  170.